<!--
 * @description  : 证件-实地核查列表
 * @descriptionDetail: 证件-实地核查列表
 * @copyright    : 浙江烟草
 * @author       : fzp
 * @create       : 2022-09-28 17:30:45
-->
<template>
  <u-card padding="0" :border="false" margin="0" :head-style="{ padding: '10px 5px' }" :foot-style="{ padding: '5px 10px' }">
    <view class="process-head" slot="head">
      <u-row gutter="16" style="width:100%">
        <u-col span="3">
          <view class="u-head-item u-flex">
            <image :src="getIcon(sealInfo.applyType)" style="width:34rpx;height:34rpx" />
           <view class="u-head-item-title" :style="{ color: getTextColor(sealInfo.applyType), marginLeft: '5px' }">{{sealInfo.applyTypeName}}</view>
          </view>
        </u-col>
        <u-col span="6" text-align="center">
          <view class="u-head-item-title u-col-line-1" style="font-size:14px;color:#000000;">{{sealInfo.applyCode}}</view>
        </u-col>
        <u-col span="3" text-align="right">
          <u-icon v-if="type == 0" label="撤回申请" size="26" name="arrow-right" margin-right="8" label-pos="left" label-color="#999999" @click="revokeHandleApply"/>
					<u-icon v-else label="打印文书" size="26" name="arrow-right" margin-right="8" label-pos="left" label-color="#999999" @click="printHandleApply"/>
        </u-col>
      </u-row>
    </view>
    <view class="process-body" slot="body">
      <view class="u-body-item-licno" style="color:#333333;padding:5px 10px 0;font-size:13px">
        {{sealInfo.licNo}}
      </view>
      <view class="u-body-item-shop" style="color:#333333;padding:5px 10px 0;margin-bottom:5px;font-size:13px">
         {{sealInfo.companyName}}
      </view>
      <view class="u-body-day" style="background:#f6f6f6;padding:5px 15px;">
        <u-row gutter="16" style="width:100%;padding:0x 15px" justify="between">
          <u-col span="6" text-align="center">
            <view class="u-body-remaining-day">
              剩余办理天数
            </view>
            <view class="u-body-true-day" style="color:#dd6161;padding:5px 0;font-weight:bold">
              {{sealInfo.promiseHandleDays?sealInfo.promiseHandleDays:"0"}}
            </view>
            <view class="u-body-remaining-day">
              <u-tag :text=" '申请时间：' + $u.timeFormat(sealInfo.applyDate, 'yyyy-mm-dd')" shape="circle" type='error' />
            </view>
          </u-col>
          <u-col span="5">
            <view class="u-body-approve-text" style="color:#aaaaa;font-size:13px;">受理日期</view>
            <view class="u-body-approve-day" style="color:#aaaaa;font-size:13px;">{{sealInfo.acceptFinishDate ? sealInfo.acceptFinishDate : "-" }}</view>
            <u-line color="#cccccc" margin="5px 0px 5px -1px" />
            <view class="u-body-decision-text" style="color:#aaaaa;font-size:13px;">决定日期</view>
            <view class="u-body-decision-day" style="color:#aaaaa;font-size:13px;">{{sealInfo.decideDate ? sealInfo.decideDate:"-"}}</view>
          </u-col>
        </u-row>
      </view>
    </view>
    <view class="process-foot" slot="foot">
      <view class="u-foot-item u-flex">
        <view class="u-foot-item-name" style="color:#333333;margin-right:10px">{{sealInfo.managerName}}</view>
        <view class="u-foot-item-phone" style="color: #2b85e4" @click="handlerShowPhone">{{sealInfo.contactTel}}</view>
      </view>
      <view class="u-foot-item-address" style="margin-top:5px; color:#333333">
        {{sealInfo.businessAddrStreet}}
      </view>
    </view>
  </u-card>
</template>

<script>
	import certificateService from "@/service/certificate/certificate.service.js";
	
// 01:新办 #2979ff
// 02:变更 #fa3534
// 03:延续 #ff9900
// 04:停业 #909399
// 05:恢复 #19be6b
// 06:补办 #303133
// 07:歇业 #dcdfe6
let styleParams = [
  {
    id: "01",
    label: "新办",
    color: "#2979ff",
    icon: require("@/static/personalization/new.png"),
  },
  {
    id: "02",
    label: "变更",
    color: "#fa3534",
    icon: require("@/static/personalization/change.png"),
  },
  {
    id: "03",
    label: "延续",
    color: "#ff9900",
    icon: require("@/static/personalization/extend.png"),
  },
  {
    id: "04",
    label: "停业",
    color: "#909399",
    icon: require("@/static/personalization/stop.png"),
  },
  {
    id: "05",
    label: "恢复营业",
    color: "#19be6b",
    icon: require("@/static/personalization/resume.png"),
  },
  {
    id: "06",
    label: "补办",
    color: "#303133",
    icon: require("@/static/personalization/renew.png"),
  },
  {
    id: "07",
    label: "歇业",
    color: "#dcdfe6",
    icon: require("@/static/personalization/close.png"),
  },
];

export default {
  name: "processingItem",
  props: {
    sealInfo: {
      type: Object,
      required: true,
    },
		type: {
		  type: Number,
		  required: true,
		},
  },
  data() {
    return {
      styleParams: styleParams,
    };
  },
  methods: {
    getTextColor(id) {
      let color = this.styleParams.find((item) => item.id == id).color;
      return color;
    },
    getIcon(id) {
			console.log(id)
      let image = this.styleParams.find((item) => item.id == id).icon;
      return image;
    },
		revokeHandleApply() {
			console.log(JSON.stringify(this.sealInfo),'22222222');
			 this.$modal.showLoading('加载中...');
			certificateService.getWithDrawDoc({bizUuid:this.sealInfo.handleMainUuid}).then((res)=>{
				console.log(res,"eeeee")
				this.$modal.hideLoading();
				if(res.success) {
					this.setRouteParam({
            id: res.bean.id,
            docUuid: res.bean.docUuid,
            titemUuid: res.bean.titemUuid,
					  bizUuid: this.sealInfo.handleMainUuid
					});
					this.$u.route('pages/certificate/official/licWithdrawApply');
				} else {
					this.$u.toast(res.msg);
				}
				
			}).catch((err)=>{
				console.log(err);
				this.$modal.hideLoading();
				this.$u.toast('请求失败:' + e);
			})
			
		},
		printHandleApply(){
			certificateService.getWithDrawDoc({bizUuid:this.sealInfo.handleMainUuid}).then((res)=>{
				if (res.success) {
          if (res.bean.pdfFileId) {
            this.setRouteParam({
              isDownload: true,
              fileId: res.bean.pdfFileId,
              fileName: '烟草专卖许可证撤回申请办理登记表'
            })
            this.$u.route('pages/commonPage/printerComponent')
          } else {
            this.$u.toast('文书未生成！')
          }
        }
			}).catch((err)=>{
				console.log(err)
			})
		},
    // 显示联系电话
    handlerShowPhone(e) {
      let tels = [];
      if(this.sealInfo.contactTel == null || this.sealInfo.contactTel == ''){
        this.$modal.alert("当前记录未维护电话");
        return;
      }else{
        tels = this.sealInfo.contactTel.split(',');
      }
      if (tels.length > 0) {
        // 此处不能使用u-action-sheet，在u-swipe-action中使用时样式异常
        uni.showActionSheet({
          itemList: tels,
          itemColor: this.$theme.u_type_primary,
          success: ({tapIndex,}) => this.doPhone(tels[tapIndex]),
        });
        return;
      }
      e.stopPropagation();
      e.preventDefault();
    },
    // 拨打电话
    doPhone(telStr) {
      let tel = telStr.substring(telStr.indexOf(" "));
      this.$deviceApi.makePhoneCall(tel);
    }
  },
};
</script>

<style lang="scss" scoped>
.page {
  padding: 0;
}
/deep/ .u-card__foot::after {
  border: none;
}
</style>
